#!/etc/bin/env python
# encoding:utf-8
# li = ["abc","aric","Alec","Tony","rain"]
# temp_li = []
# tu = ["alec","aric","Alex","Tony","rain"]
# dic = {"k1":"alex","k2":'aric',"k3":"Alex","k4":'Tony'}
# for i in li:
#     if i.startswith('a') or i.startswith('A') and i.endswith('c'):
#         temp_li.append(i)
# print(temp_li)

# li =  ['手机',"电脑","鼠标垫","游艇"]
# for index,i in enumerate(li):
#     print(index),
#     print(i)
# inp = raw_input("请输入产品序号：")
# print(li[int(inp)])
# print li

# __metaclass__ = type
# class Persion:
#     def __init__(self,name):
#         self.name = name
#
#     def getName(self):
#         return gil.name
#
# gil = Persion('canglaoshi')
# name = gil.getName()
# print name

# def outer_foo():
#     a = 10
#     def inner_foo():
#         a = 20
#         print "inner_foo,a=",a
#     inner_foo()
#     print "outer_foo,a",a
# a = 30
# outer_foo()
# print "a=",a

# IND = 'ON'
# def checkind():
#     return (IND == "ON")
# class Kls(object):
#     def __init__(self,data):
#         self.data = data
#     def do_reset(self):
#         if checkind():
#             print ('Reset done for:',self.data)
#             # self.db = 'new db connection'
#     def set_db(self):
#         if checkind():
#             print ('Db connection made for:',self.data)
#             print (self.db)
# ik1 = Kls('aa')
# ik1.do_reset()
# ik1.db = 'abc'
# ik1.set_db()
#
# class Kls(object):
#     def __init__(self,data):
#         self.data = data
#     def printd(self):
#         print (self.data)
#     @staticmethod
#     def smethod(*arg):
#         print ('Static:',arg)
#     @classmethod
#     def cmethod(*arg):
#         print ('Class:',arg)
# ik = Kls(23)
# ik.printd()
# ik.smethod()
# ik.cmethod()
# # Kls.printd()
# Kls.smethod()
# Kls.cmethod()


# x1 = 1
# d = 3
# n = 0
# x100 = 0
#
# while n <100:
#     s1 = x1+n*d
#     x100 = s1+x100
#     n+=1
#     print s1 , x100
#
# age = 20
# if age >= 6 and age <18:
#     print 'teenager'
# elif age >= 18:
#     print 'adult'
# else:
# #     print 'kid'
#
# L = [75, 92, 59, 68]
# sum = 0.0
# for score in L:
#     sum = sum +score
#     print sum
# print sum / 4
#
# for x in [ 9,8,7,6,5,4,3,2,1 ]:
#     for y in [ 9,8,7,6,5,4,3,2,1,0 ]:
#         if y > x:
#             print 10*x+y ,

# d = {
#     'Adam': 95,
#     'Lisa': 85,
#     'Bart': 59
# }
# for l in d:
#     print l,':',d[l]

# s = set(['Adam', 'Lisa', 'Paul'])
# L = ['Adam', 'Lisa', 'Bart', 'Paul']
# for a in L:
#     if a in s:
#         s.remove(a)
#     else:
#         s.add(a)
# print s
#
# def square_of_sum(L):
#     sum = 0
#     for a in L:
#         sum = sum+a*a
#
#     return sum
# print square_of_sum([1, 2, 3, 4, 5])
# print square_of_sum([-5, 0, 5, 15, 25])

# def greet(name = 'world'):
#     print 'hello,'+ name
# greet()
# greet('Bart')
# import math
# def average(*args):
#     if len(args) == 0:
#         return 0
#     else:
#         return float(sum(args))/len(args)
# print average()
# print average(1, 2)
# print average(1, 2, 2, 3, 4)
#
# for i in range(1,101):
#     if i%7 == 0:
#         print i
#
# L = ['Adam', 'Lisa', 'Bart', 'Paul']
# for index, name in zip(L,range(1,len(L)+1)):
#     print index, '-', name

#d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
#
# sum = 0.0
# for v in d.itervalues():
#     sum = sum+v
# print sum/len(d.values()) ,sum , len(d.values())
#
# d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
#
# # sum = 0.0
# # for k, v in d.items():
# #     sum = sum + v
# #
# #     print k,':',v
# # print 'average', ':', sum/len(d)
#
# for name, score in d.iteritems():
#      print name,score

# def toUppers(L):
#     return [x.upper() for x in L if  isinstance(x,str)]
#
# print toUppers(['Hello', 'world', 101])

# def format_name(s):
#     # return s.title()
#     return s[0].upper() + s[1:].lower()
# print map(format_name, ['adam', 'LISA', 'barT'])
#
# def cmp_ignore_case(s1, s2):
#     u1 = s1.upper()
#     u2 = s2.upper()
#     if u1 < u2:
#         return -1
#     if u1 > u2:
#         return 1
#     return 0
# print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
#
# def f():
#     print 'call f()...'
#     # 定义函数g:
#     def g():
#         print 'call g()...'
#     # 返回函数g:
#     return g
# x = f()
# print x

#
# import os
# print os.path.isfile('E:/py/test.py')
# print os.path.isdir('E:/py')

# class Person(object):
#     a = '123'
#     def __init__(self,name,gender,birth,**kw):
#         self.name = name
#         self.gender = gender
#         self.birth = birth
#         for k,v in kw.iteritems():
#             setattr(self,k,v)
#
# xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student',job1='23123')
#
# print xiaoming.name
# print xiaoming.job ,xiaoming.job1
# print Person.a
#
# class Person(object):
#     __count = 0
#     def __init__(self, name):
#         Person.__conut = Person.__conut+1
#         print Person.__count
#
# p1 = Person('Bob')
# p2 = Person('Alice')
# #print Person.__count
#
# class Person(object):
#     def __init__(self, name, score):
#         self.name = name
#         self.__score = score
#
#     def get_grade(self):
#         if self.__score >= 80:
#             return self.name +' '+  'A-优秀'
#         if self.__score >= 60 and self.__score < 80:
#             return self.name +' '+ 'B-及格'
#         else:
#             return self.name +' '+ 'C-不及格'
#
#
# p1 = Person('Bob', 90)
# p2 = Person('Alice', 65)
# p3 = Person('Tim', 48)
#
# print p1.get_grade()
# print p2.get_grade()
# print p3.get_grade()


# class Person(object):
#     def __init__(self, name, gender):
#         self.name = name
#         self.gender = gender
#
# class Teacher(Person):
#
#     def __init__(self, name, gender, course):
#         super(Teacher,self).__init__(name,gender)
#         self.course = course
# t = Teacher('Alice', 'Female', 'English')
# print t.name
# print t.gender
# print t.course

# class BasketballMixin(object):
#     def skill(self):
#         return 'basketball'
#
# class Bstudent(BasketballMixin):
#     pass
# s = Bstudent()
# print s.skill()

# import copy
# class MyCopy(object):
#     def __init__(self,value):
#         self.value = value
#     def __repr__(self):
#         return str(self.value)
# foo = MyCopy(7)
# print foo
# a = ['foo',foo]
# print a
# print type(a)
#
# import time
# time.strftime()

# import urllib
# baidu = urllib.urlopen('http://www.baidu.com')
# # print baidu.info()
# # print baidu.getcode()
# # print baidu.geturl()
# urllib.urlretrieve('http://www.baidu.com','d:/baidu.html')



# s = 'abc'
# s1 = '老师好'
# print(len(s))
# print(len(s1))

# import math
# a = math.sqrt(4)
# print(a)


